package com.cy;

import jdk.internal.org.objectweb.asm.tree.MultiANewArrayInsnNode;

import java.io.PrintWriter;
//泛型的通用性
public class Test2 {
    public static void main(String[] args) {

        String [] a = {"jack","Rose","杨幂","王菲","谢霆锋","王祖蓝","陈冠希","小s"};
        print(a);

        Integer [] b= {1,2,3,4};
        print(b);
    }

    /**
     *   //高效for循环/foreach循环:两个使用场景:数组|Collection集合
     * 		        //语法:for( 遍历得到的数据的类型  变量名 : 要遍历的是啥){循环体}
     * @param x
     * @param <E>
     */
    private static <E> void print(E[] x) {
        for(E s: x){

            System.out.println(s);
        }

        for(int i = 0; i<x.length;i++){

            System.out.println(x[i]);
        }
    }
}
